char recept;

int identify (int id, int mes)
{
          if (mes <= 9) mes = mes + 10*id;
          else if (mes <= 99) mes = mes + 100*id;
          else if (mes <= 999) mes = mes + 1000*id;
          else if (mes <= 9999) mes = mes + 10000*id;
          return mes;
}

void main() {

unsigned int toto;
int mesure;
char *text= "";

INTCON = 0x90;
ADCON1     = 0x82;
TRISA      = 0xFF;

Usart_Init(2400);

while (1) {
        if (Usart_Data_Ready())
          {
              recept = Usart_Read();
              Delay_us(10);
              IntToStr(0, text);
              switch (recept)
              {
                    case '1':
                    mesure  = ADC_read(0);
                    mesure = identify(1,mesure);
                    IntToStr(mesure, text);
                    toto = 0;
                    text[6] = 0x0A;
                    text[7] = 0x0D;
                        while ( text[toto] != 0x0D)
                          {
                          toto =toto+1;
                          Usart_Write(text [toto]);
                          }
                    break;

                    case '2':  mesure  = ADC_read(1);
                    mesure = identify(2,mesure);
                    IntToStr(mesure, text);
                    toto = 0;
                    text[6] = 0x0A;
                    text[7] = 0x0D;
                        while ( text[toto] != 0x0D)
                              {
                              toto =toto+1;
                              Usart_Write(text [toto]);
                              }
                        break;
                     default : break;
                    }

          }
      }
}